﻿/*
版权所有：版权所有(C) 2011，刘建新
文件编号：M01_Couponused.cs
文件名称：Couponused.cs
系统编号：Z0003007
系统名称：通用办公系统
模块编号：M01
模块名称：信息发布
设计文档：IOA_M01信息发布XDE建模.mdx
完成日期：2011-6-11
作　　者：
内容摘要：表[CouponUsed]对应的实体类
*/

using System;
using System.Collections;
using System.Data;


namespace Eis51.CampanyCMS.Model.Bus
{
		/// <summary>
		/// 类 编 号：
		/// 类 名 称：Couponused
		/// 内容摘要：
		/// </summary>
		
		[Serializable]
		public class Couponused : BaseModel
		{
		#region 自动生成代码
		
			#region 重载Equals/GetHashCode
			/// <summary>
			/// 重载Equals			
			/// </summary>
			public override bool Equals (Object obj)
			{
				if (obj != null && obj is Couponused)
				{
					if (obj == this)
						return true;
					Couponused castObj = (Couponused)obj; 
					
					if (!this.m_Couponusedid.Equals(castObj.Couponusedid))
						return false;
						
					if (!this.m_Couponno.Equals(castObj.Couponno))
						return false;
						
					if (!this.m_Username.Equals(castObj.Username))
						return false;
						
					if (!this.m_Orderno.Equals(castObj.Orderno))
						return false;
						
					if (!this.m_Amount.Equals(castObj.Amount))
						return false;
						
					return true;
				}
				return false;
			}
			
			/// <summary>
			/// 重载GetHashCode
			/// </summary>
			public override int GetHashCode()
			{
					int hash = 0;					
					
					hash = hash <<  8;
					if ((object)m_Couponusedid != null)
					{
						hash = hash ^ m_Couponusedid.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Couponno != null)
					{
						hash = hash ^ m_Couponno.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Username != null)
					{
						hash = hash ^ m_Username.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Orderno != null)
					{
						hash = hash ^ m_Orderno.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Amount != null)
					{
						hash = hash ^ m_Amount.GetHashCode();
					}
						
					return hash; 
			}
			#endregion
			
			public Couponused()
			{
				MarkNew();
			}						
			
			public Couponused GetOldValue()
			{
				return OldValue as Couponused;
			}
		
		#region Couponusedid属性
			private int m_Couponusedid = 0;
			/// <summary>
			/// 属性名称： Couponusedid
			/// 内容摘要： DB列名：CouponUsedid[]
			///            DB类型：int
			/// </summary>
			public int Couponusedid
			{
				get
					{
						return m_Couponusedid;
					}
				set
					{
						if (m_Couponusedid as object == null || !m_Couponusedid.Equals(value))
						{
							m_Couponusedid = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Couponno属性
			private string m_Couponno = String.Empty;
			/// <summary>
			/// 属性名称： Couponno
			/// 内容摘要： DB列名：CouponNo[]
			///            DB类型：string
			/// </summary>
			public string Couponno
			{
				get
					{
						return m_Couponno;
					}
				set
					{
						if (m_Couponno as object == null || !m_Couponno.Equals(value))
						{
							m_Couponno = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Username属性
			private string m_Username = String.Empty;
			/// <summary>
			/// 属性名称： Username
			/// 内容摘要： DB列名：UserName[]
			///            DB类型：string
			/// </summary>
			public string Username
			{
				get
					{
						return m_Username;
					}
				set
					{
						if (m_Username as object == null || !m_Username.Equals(value))
						{
							m_Username = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Orderno属性
			private string m_Orderno = String.Empty;
			/// <summary>
			/// 属性名称： Orderno
			/// 内容摘要： DB列名：Orderno[]
			///            DB类型：string
			/// </summary>
			public string Orderno
			{
				get
					{
						return m_Orderno;
					}
				set
					{
						if (m_Orderno as object == null || !m_Orderno.Equals(value))
						{
							m_Orderno = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Amount属性
			private double m_Amount = 0;
			/// <summary>
			/// 属性名称： Amount
			/// 内容摘要： DB列名：Amount[]
			///            DB类型：double
			/// </summary>
			public double Amount
			{
				get
					{
						return m_Amount;
					}
				set
					{
						if (m_Amount as object == null || !m_Amount.Equals(value))
						{
							m_Amount = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region static CreateDataTable/FillDataRow/DataRow2Obj/Dt2Objs/FillDataTable
			/// <summary>
			/// 得到实体对应的DataTable
			/// </summary>
			/// <param name="tableName">表名</param>
			/// <param name="cne">列名映射选择:DB列名或属性名</param>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable(string tableName,ColumnNameEnum cne)
			{
				DataTable dtResult = new DataTable(tableName);
			
				if (cne == ColumnNameEnum.DBName)
				{
					dtResult.Columns.Add(new DataColumn("CouponUsedid",typeof(int)));
					dtResult.Columns.Add(new DataColumn("CouponNo",typeof(string)));
					dtResult.Columns.Add(new DataColumn("UserName",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Orderno",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Amount",typeof(double)));
				}
				else if (cne == ColumnNameEnum.PropertyName)
				{
					dtResult.Columns.Add(new DataColumn("Couponusedid",typeof(int)));
					dtResult.Columns.Add(new DataColumn("Couponno",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Username",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Orderno",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Amount",typeof(double)));
				}
				return dtResult;
			}
			
			/// <summary>
			/// 得到实体对应的DataTable
			/// </summary>
			/// <param name="cne">列名映射选择:DB列名或属性名</param>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable(ColumnNameEnum cne)
			{
				return CreateDataTable(null,cne);
			}

			/// <summary>
			/// 得到实体对应的DataTable(默认列名映射为属性名)
			/// </summary>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable()
			{
				return CreateDataTable(ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 用当前对象值填充DaraRow
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			/// <param name="cne">dr的列名映射方式:DB列名或属性名</param>
			public void FillDataRow(DataRow dr,ColumnNameEnum cne)
			{
				if (dr == null)
				{
					throw new ArgumentNullException("dr");
				}
				if (ColumnNameEnum.DBName == cne)
				{
					dr["CouponUsedid"] = this.Couponusedid;
					dr["CouponNo"] = this.Couponno;
					dr["UserName"] = this.Username;
					dr["Orderno"] = this.Orderno;
					dr["Amount"] = this.Amount;
				}
				else if (ColumnNameEnum.PropertyName == cne)
				{
					dr["Couponusedid"] = this.Couponusedid;
					dr["Couponno"] = this.Couponno;
					dr["Username"] = this.Username;
					dr["Orderno"] = this.Orderno;
					dr["Amount"] = this.Amount;					
				}
			}
			
			/// <summary>
			/// 用当前对象值填充DaraRow(默认列名映射为属性名)
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			public void FillDataRow(DataRow dr)
			{
				this.FillDataRow(dr,ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 将DataRow转换成Couponused对象
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			/// <param name="cne">dr的列名映射方式:DB列名或属性名</param>
			/// <returns>Couponused对象</returns>
			public static Couponused Dr2Obj(DataRow dr,ColumnNameEnum cne)
			{
				if (dr == null)
				{
					throw new ArgumentNullException("dr");
				}
				Couponused obj = new Couponused();
				if (ColumnNameEnum.DBName == cne)
				{
					obj.Couponusedid = (dr["CouponUsedid"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["CouponUsedid"],typeof(int));
					obj.Couponno = (dr["CouponNo"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["CouponNo"],typeof(string));
					obj.Username = (dr["UserName"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["UserName"],typeof(string));
					obj.Orderno = (dr["Orderno"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Orderno"],typeof(string));
					obj.Amount = (dr["Amount"] == Convert.DBNull) ? 0  : (double)Convert.ChangeType(dr["Amount"],typeof(double));
				}
				else if (ColumnNameEnum.PropertyName == cne)
				{
					obj.Couponusedid = (dr["Couponusedid"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Couponusedid"],typeof(int));
					obj.Couponno = (dr["Couponno"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Couponno"],typeof(string));
					obj.Username = (dr["Username"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Username"],typeof(string));
					obj.Orderno = (dr["Orderno"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Orderno"],typeof(string));
					obj.Amount = (dr["Amount"] == Convert.DBNull) ? 0  : (double)Convert.ChangeType(dr["Amount"],typeof(double));		
				}
				
				return obj;
			}
			
			/// <summary>
			/// 将DataRow转换成Couponused对象(默认列名映射为属性名)
			/// </summary>
			/// <returns>Couponused对象</returns>
			public static Couponused Dr2Obj(DataRow dr)
			{
				return Dr2Obj(dr,ColumnNameEnum.DBName);
			}
			
			/// <summary>
			/// 将DataTabe转换成的Couponused对象集合
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="cne">dt的列名映射方式:DB列名或属性名</param>
			/// <returns>Couponused对象的集合</returns>
			public static IList Dt2Objs(DataTable dt,ColumnNameEnum cne)
			{
				if (dt == null)
				{
					throw new ArgumentNullException("dt");
				}
				
				ArrayList alResult = new ArrayList();
				
				foreach(DataRow dr in dt.Rows)
				{
					alResult.Add(Dr2Obj(dr,cne));
				}
				
				return alResult;
			}

			/// <summary>
			/// 将DataTabe转换成的Couponused对象集合(默认列名映射为属性名)
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <returns>Couponused对象的集合</returns>
			public static IList Dt2Objs(DataTable dt)
			{
				return Dt2Objs(dt,ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 用objs的Couponused对象集合填充DataTable
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="objs">Couponused对象集合</param>
			/// <param name="cne">dt的列名映射方式:DB列名或属性名</param>
			public static void FillDataTable(DataTable dt,IList objs,ColumnNameEnum cne)
			{
				if (dt == null)
				{
					throw new ArgumentNullException("dt");
				}
				if (objs == null)
				{
					throw new ArgumentNullException("objs");
				}
				
				foreach(Couponused obj in objs)
				{
					DataRow dr = dt.NewRow();
					obj.FillDataRow(dr,cne);
					dt.Rows.Add(dr);
				}
			}

			/// <summary>
			/// 用objs的Couponused对象集合填充DataTable(默认列名映射为属性名)
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="objs">Couponused对象集合</param>
			public static void FillDataTable(DataTable dt,IList objs)
			{
				FillDataTable(dt,objs,ColumnNameEnum.PropertyName);
			}
		#endregion
		
		/// <summary>
		/// 取消编辑,恢复到上次有效调用BeginEdit前的状态,并清空保留值
		/// </summary>
		public override void CancelEdit()
		{
			Couponused old = this.OldValue as Couponused;
			if (old != null)
			{
					this.Couponusedid = old.Couponusedid;
					this.Couponno = old.Couponno;
					this.Username = old.Username;
					this.Orderno = old.Orderno;
					this.Amount = old.Amount;				
				this.OldValue = null;
			}
		}
		
		
		
		
		#region Couponused实体的内部Key类
			/// <summary>
			/// Couponused实体的Key类
			/// </summary>
			public sealed class Key
			{
		
				private int m_Couponusedid;
				public int Couponusedid
				{
 					get 
					{ 
						 return m_Couponusedid; 
					}
					set 
					{ 
						m_Couponusedid = value;
					}
				}
		
				public Key(int pCouponusedid)
				{
					m_Couponusedid=pCouponusedid;

				}
			}
		#endregion
			/// <summary>
			/// 得到实体Couponused的PK
			/// </summary>
			public Key GetKey()
			{
				return new Key(Couponusedid);				
			}
			
				
		#endregion
	}
}
